package com.company;

import java.util.Iterator;
import java.util.function.Predicate;

public class DataStructure {
    private final static int SIZE = 15;
    private int[] arrayOfInts = new int[SIZE];

    public DataStructure() {
        for (int i = 0; i < SIZE; i++) {
            arrayOfInts[i] = i;
        }
    }

    public void printEven() {
        EvenIterator ei = new EvenIterator();
        while (ei.hasNext()) {
            System.out.print(ei.next() + " ");
        }

    }

    interface DataStructureIterator extends Iterator<Integer> {
    }

    private class EvenIterator implements DataStructureIterator {

        private int nextIndex = 0;

        public boolean hasNext() {
            return nextIndex <= SIZE - 1;
        }

        @Override
        public Integer next() {
            int resInt = arrayOfInts[nextIndex];
            nextIndex += 2;
            return resInt;
        }
    }

    public static void main(String[] args) {
        DataStructure ds = new DataStructure();
        ds.printEven();
    }
}
